<?php

class Ddup_Featured_Block_Adminhtml_Products_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form 
{	
	protected function _prepareForm()
	{
		$form = new Varien_Data_Form();
		$this->setForm($form);
		
		$fieldset = $form->addFieldset('product_group_form', array(
            'legend'=>Mage::helper('featured')->__('Product Group Information')
        ));
        
		if ($this->getProductsGroup() && $this->getProductsGroup()->getId()) {
            $fieldset->addField('featured_products_id', 'hidden', array(
                'name' => 'id',
            ));
        }
        
        $fieldset->addField('title', 'text', array(
            'name'      => 'title',
            'label'     => Mage::helper('featured')->__('Title'),
            'class'     => 'required-entry',
            'required'  => true,
        ));
        
        $fieldset->addField('is_random', 'select', array(
            'name'      => 'is_random',
            'label'     => Mage::helper('featured')->__('Random'),
            'class'     => 'required-entry',
            'required'  => true,
        	'options'    => array(
                '1' => Mage::helper('featured')->__('Yes'),
                '0' => Mage::helper('featured')->__('No'),
            ),
        ));
        
        $fieldset->addField('show_qty', 'text', array(
            'name'      => 'show_qty',
            'label'     => Mage::helper('featured')->__('Qty'),
            'class'     => 'required-entry',
            'required'  => true,
        ));
        
        if ($this->getProductsGroup() && $this->getProductsGroup()->getData() ) {
        	$form->setValues($this->getProductsGroup()->getData());
        }
	}
    
    public function getProductsGroup()
    {
    	return Mage::registry('products_group_data');
    }
}